package org.hawk.gwt.ppc.introspection.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.hawk.gwt.ppc.introspection.JavaModifier;
import org.hawk.gwt.ppc.introspection.JavaStatement;

/**
 * Implementation of basic java statement methods.
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
abstract class AbstractJavaStatement implements JavaStatement {
	
	private List<JavaModifier> modifiers;
	
	AbstractJavaStatement() {
	}
	
	void setModifiers(List<JavaModifier> modifiers) {
		this.modifiers = Collections.unmodifiableList(modifiers);
	}

	/* (non-Javadoc)
	 * @see org.hawk.gwt.ppc.introspection.JavaStatement#getModifiers()
	 */
	public List<JavaModifier> getModifiers() {
		return modifiers;
	}
	
	/**
	 * @param strings
	 * @return modifiers parsed from list of the strings.
	 */
	static List<JavaModifier> fromStrings(List<String> strings) {
		List<JavaModifier> result = new ArrayList<JavaModifier>(strings.size());
		for (String mod : strings) {
			result.add(JavaModifier.valueOf(mod.toUpperCase()));
		}
		return result;
	}
}
